package sctu.edu.java.year2016.team01.xuhanmei.day20160618;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * Created by Administrator on 2016/6/18.
 */
public class GameFrame extends Frame {
    Image img= GameUtil.getImage("images/gun1.jpg");//????
    int x=100,y=100;
    public void LaunchFrame() {//窗体
        setSize(500, 500);
        setLocation(100, 100);
        setVisible(true);


        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
    }
    @Override
    public void paint(Graphics g){
        g.drawLine(100, 100, 200, 200);

        Color c=g.getColor();//在使用画笔之前，先将画笔颜色存起来。
        g.setColor(Color.MAGENTA);//设置颜色
        g.drawOval(100, 100, 200, 200);//画空心圆
        g.setColor(c);//用完画笔颜色之后将画笔颜色改回去。

        g.setColor(Color.blue);
        g.fillOval(100, 100, 30, 30);//画实心圆
        g.setColor(c);

        Font font=new Font("正楷", Font.BOLD, 80);//字体，style，size
        g.setFont(font);
        g.setColor(Color.orange);
        g.drawString("我是一个字符串，欢快的字符串",100,200);//在窗口中写入字符串
        g.setColor(c);
        g.drawImage(img,x,y,null);//在移动的图片
        x+=3;//移动的条件
        y+=3;
    }

    public static void main(String[] args) {
        GameFrame gf = new GameFrame();
        gf.LaunchFrame();
    }
}
